package org.minos.edit.view
{
	import flash.events.Event;
	import org.minos.edit.EditFacate;
	import org.minos.edit.view.components.ToolBar;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	/**
	 * ...
	 * @author Minos
	 */
	public class ToolBarMediator extends Mediator
	{
		public static const NAME : String = "ToolBarMediator";
		
		public function ToolBarMediator( v : ToolBar )
		{
			super( NAME , v );
		}
		
		public function get toolBar() : ToolBar
		{
			return viewComponent as ToolBar;
		}
		
		override public function onRegister() : void
		{
			super.onRegister();
			toolBar.getAddItemButton().addActionListener( onAddItem );
		}
		
		private function onAddItem( e : Event ) : void
		{
			trace("add");
		}
		
		override public function onRemove() : void
		{
			super.onRemove();
		
		}
		
		override public function listNotificationInterests() : Array
		{
			return [ EditFacate.SCENE_SELECTION_CHANGED ];
		}
		
		override public function handleNotification( notification : INotification ) : void
		{
			super.handleNotification( notification );
			switch ( notification.getName() )
			{
				case EditFacate.SCENE_SELECTION_CHANGED: 
					var selection : Boolean = ( notification.getBody() != null );
					toolBar.getEditItemButton().setEnabled( selection );
					toolBar.getRemoveItemButton().setEnabled( selection );
					break;
			}
		}
	}

}